package com.ecommerce.dal.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ecommerce.dal.dao.IItemDetailDAO;
import com.ecommerce.dal.entity.ItemDetail;
import com.ecommerce.dal.util.CustomHibernateDAOSupport;

@Repository("itemDetailDAO")
public class ItemDetailDAO extends CustomHibernateDAOSupport implements
		IItemDetailDAO {

	@Override
	public void save(ItemDetail itemDetail) {
		getHibernateTemplate().save(itemDetail);

	}

	@Override
	public void update(ItemDetail itemDetail) {
		getHibernateTemplate().update(itemDetail);

	}

	@Override
	public void delete(ItemDetail itemDetail) {
		getHibernateTemplate().delete(itemDetail);

	}

	@Override
	public List<ItemDetail> findByItemId(long itemId) {
		List list = getHibernateTemplate().find(
				"select itemDetail from ItemDetail itemDetail inner join itemDetail.item item where item.itemId=?", itemId);
		return ((list != null && list.size()>0) ?  list : null) ;
	}

}
